package com.database;

import java.security.MessageDigest;

public class MD5utils {

	public static String encode(String password){
		try {
			MessageDigest digest = MessageDigest.getInstance("md5");
			byte[] results = digest.digest(password.getBytes());
			StringBuilder sb = new StringBuilder();
			for(byte b : results){
				int number = b&0xff;
				String hex = Integer.toHexString(number);
				if(hex.length()==1){
					sb.append("0");
				}
				sb.append(hex);
			}
			return sb.toString();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "";
		}
		
	}
}
